# -*- coding: utf-8 -*- 
from m_database import MyDatabaseTmall
from m_main import scrapyEngine,Task


if __name__=='__main__':
    #此项任务量大，几乎不可能全部完成，所以采用循环进行
    #j=1
    while True:
        print '1'
        ilist=[]
        db=MyDatabaseTmall()
        mytuple=db.fetchdata('select userid,usercode,fullname from customer where usetag is null and usercode is not null order by rand() limit 200')
        print 'ok'
        for x,y,z in mytuple:
            mytask=Task()
            mytask.taskname='customer_judge'
            mytask.to_downloader='Downloader_Common'
            mytask.to_spider='Spiders_Findcustomer_judgerecord'
            mytask.url='http://rate.taobao.com/member_rate.htm?callback=shop_rate_list&content=1&result=&from=rate&user_id='+y+'&identity=1&rater=3&direction=1&page=1'
            mytask.header={'Refer':'http://detail.tmall.com/item.htm?id='+x}
            mytask.addin_data={'userid':x,'user_fullname':z,'usercode':y}
            #print j,mytask.url
            #j+=1
            ilist.append(mytask)
        scrapyEngine(ilist)
